package com.chengww.grab_rp.database.redpocket

import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query

/**
 * Created by chengww on 2/20/21
 * @author chengww
 */
@Dao
interface RedPocketDao {
    @Query("SELECT * FROM red_pocket")
    fun getRedPockets(): List<RedPocket>

    @Query("SELECT * FROM red_pocket")
    fun getRedPocketsLive(): LiveData<List<RedPocket>>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(redPocket: RedPocket)

    @Query("DELETE FROM red_pocket")
    fun deleteAll()

    @Query("DELETE FROM red_pocket where rpSn = :rpSn")
    fun delete(rpSn: String)
}